package main

import "github.com/gin-gonic/gin"

func testAPI(c *gin.Context) {
	c.JSON(200, gin.H{
		"retCode": 0,
		"msg":     "success",
	})
}

func bookGet(c *gin.Context) {
	c.JSON(200, gin.H{
		"retCode": 0,
		"msg":     "This is bookGet",
	})
}

func bookPost(c *gin.Context) {
	c.JSON(200, gin.H{
		"retCode": 0,
		"msg":     "This is bookPost",
	})
}

func bookPut(c *gin.Context) {
	c.JSON(200, gin.H{
		"retCode": 0,
		"msg":     "This is bookPut",
	})
}

func bookDelete(c *gin.Context) {
	c.JSON(200, gin.H{
		"retCode": 0,
		"msg":     "This is bookDelete",
	})
}

func main() {
	r := gin.Default()

	// 路由
	r.GET("/api", testAPI)

	// book resuful api
	r.GET("/book", bookGet)
	r.POST("/book", bookPost)
	r.PUT("/book", bookPut)
	r.DELETE("/book", bookDelete)

	// run
	r.Run(":9090")
}
